/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package BoardGameLanguage.facade.impl;

import BoardGameLanguage.Board;
import BoardGameLanguage.BoardGameLanguageFactory;
import BoardGameLanguage.Field;

import BoardGameLanguage.facade.BoardGameUtils;
import BoardGameLanguage.facade.FacadePackage;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Board Game Utils</b></em>'. <!-- end-user-doc -->
 * <p>
 * </p>
 *
 * @generated
 */
public class BoardGameUtilsImpl extends EObjectImpl implements BoardGameUtils {
	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	protected BoardGameUtilsImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return FacadePackage.Literals.BOARD_GAME_UTILS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * Initializes width x height fields having the given board as
	 * parent and the correct row/column values set appropriately.
	 * <!-- end-user-doc -->
	 */
	public void createAllFields(Board board) {
		for (int r = 0; r < board.getHeight(); ++r) {
			for (int c = 0; c < board.getWidth(); ++c) {
				
				final Field field = BoardGameLanguageFactory.eINSTANCE
						.createField();
				
				field.setRow(r);
				field.setColumn(c);
				field.setBoard(board);
			}
		}
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments)
			throws InvocationTargetException {
		switch (operationID) {
		case FacadePackage.BOARD_GAME_UTILS___CREATE_ALL_FIELDS__BOARD:
			createAllFields((Board) arguments.get(0));
			return null;
		}
		return super.eInvoke(operationID, arguments);
	}

} // BoardGameUtilsImpl
